var copyPaperListUrl = basePath + "/sys/report/copyPaper/list";
var dataGrid;
$(function() {
	loadData();
});

function loadData() {
	dataGrid = $('#notice').datagrid({
		url : copyPaperListUrl,
		toolbar: '#tb',
		fit : true,
		fitColumns : true,
		border : true,
		pagination : true,
		idField : 'id',
		pageSize : config.pageSize,
		autoRowHeight : 140,
		pageList : config.pageList,
		queryParams : {
			approvalStatus: $("#approvalStatus").val(),
			applyTimeQuery: $("#applyTimeQuery").val(),
			approvalTimeQuery: $("#approvalTimeQuery").val()
		},
		nowrap : true,
		striped : true,
		rownumbers : true,
		columns : [ [ 
			{
				field : 'id',
				align : "center",
				width : 10,
				checkbox : true
			}, 
			{ 
				field : 'depart',
				title : '部门',
				width : 10,
				resizable : true,
				align : "center"
			}, 
			{
				field : 'applyItems',
				title : '审批明细',
				width : 30,
				align : "center",
				editor:{type:'validatebox',options:{required:true}}
			},
			{
				field : 'applyer',
				title : '申请人',
				width : 10,
				align : "center",
				editor:{type:'validatebox',options:{required:true}}
			},
			{
				field : 'applyTimeText',
				title : '申请时间',
				width : 15,
				align : "center"
			},
			{
				field : 'approver',
				title : '审批人',
				width : 15,
				align : "center",
				editor:{type:'validatebox',options:{required:true}}
			},
			{
				field : 'approvalTimeText',
				title : '审批时间',
				width : 15,
				align : "center"
			},
			{
				field : 'approvalStatusText',
				title : '审批状态',
				width : 10,
				align : "center"
			},
			{
				field : 'rejectReason',
				title : '驳回原因',
				width : 20,
				align : "center"
			},
			{
				field : 'remark',
				width : 20,
				title : '备注',
				align : "center"
			}
         ] ]
	});
}
function reload() {
	dataGrid.datagrid("clearSelections");
	searchForm("searchForm");
}

function searchForm(formId) {
	dataGrid.datagrid('load', $.serializeObject($('#' + formId)));
}
function resetForm(formId) {
	$("#" + formId).reset();
	$("#applyStartDate").datebox('setValue', '');
	$("#applyEndDate").datebox('setValue', '');
}
function exportToExcel(searchForm,exportUrl) {
	$("#" + searchForm).attr('action',exportUrl); 
	$("#" + searchForm).submit();  
}